package com.example.util

import android.graphics.BitmapFactory


/**
 * @author  chaohaipeng  on 2018/7/17.
 */
class LKImage private constructor(){
    private object mHolder {
        val instance = LKImage()
    }
    companion object {
        fun getInstance(): LKImage {
            return mHolder.instance
        }
    }

    fun getImageWidth(path:String ):Int{
        val options = BitmapFactory.Options()
        /**
         * 最关键在此，把options.inJustDecodeBounds = true;
         * 这里再decodeFile()，返回的bitmap为空，但此时调用options.outHeight时，已经包含了图片的高了
         */
        options.inJustDecodeBounds = true
        val bitmap = BitmapFactory.decodeFile(path, options) // 此时返回的bitmap为null

          return options.outWidth

    }
    fun getImageHeight(path:String ):Int{
        val options = BitmapFactory.Options()
        /**
         * 最关键在此，把options.inJustDecodeBounds = true;
         * 这里再decodeFile()，返回的bitmap为空，但此时调用options.outHeight时，已经包含了图片的高了
         */
        options.inJustDecodeBounds = true
        val bitmap = BitmapFactory.decodeFile(path, options) // 此时返回的bitmap为null
        return options.outHeight

    }

}